﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _PriceList : System.Web.UI.Page
{
    protected string sImages = string.Empty;
    protected string sPriceList = string.Empty;
    protected LocalFunctions FUNC;
    protected string sTitle;
    protected string rtBlockTitle;
    protected string rtBlockText;

    protected void Page_Load(object sender, EventArgs e)
    {
        FUNC = ((ArtCube)this.Master).FUNC;

        this.Title = sTitle = FUNC.GetPhrase(4);
        
        //Load pageData
        Dal.arParams.Clear();
        Dal.arParams.Add((int)((ArtCube)this.Master).FUNC.LangID); // Curent language
        DataSet DS = Dal.ExecuteDBspDS("GetPriceList", Dal.arParams);

        // If not null - fill fields
        if (DS != null)
        {
            if (DS.Tables[0].Rows.Count > 0)
            {
                rtBlockTitle = DS.Tables[0].Rows[0]["Title"].ToString();
                rtBlockText = DS.Tables[0].Rows[0]["Content"].ToString();
            }
            if(DS.Tables.Count>0)
                if (DS.Tables[1].Rows.Count > 0)
                {
                    string sPriceTitle = string.Empty;
                    bool bNeedClose=false;

                    for(int iCount=0;iCount<DS.Tables[1].Rows.Count;iCount++)
                    {
                        DataRow dRow = DS.Tables[1].Rows[iCount];
                        //Title
                        if (sPriceTitle != dRow["TagName"].ToString())
                        {
                            sPriceTitle = dRow["TagName"].ToString();
                            if(bNeedClose)
                            {
                                bNeedClose=false;
                                sPriceList +="</table>";
                            }
                            bNeedClose=true;
                            sPriceList += string.Format("<div class=\"typeBar\">"+
                                "<div class='divWorkTitle'><p>" +
                                "{0}</p></div></div>", sPriceTitle);
                            sPriceList += "<table class=\"tbl\" cellspacing=\"0\">";
                        }
                        sPriceList += "<tr style=\"border:1px;\">";
                        sPriceList += string.Format("<td style=\"width:280px;border-bottom:solid 1px #BAB8AC;\">{0}</td>", dRow["Description"].ToString());
                        sPriceList += string.Format("<td style=\"border-bottom:solid 1px #BAB8AC;\">{0}</td>", dRow["Price"].ToString());
                        sPriceList += "</tr>";
                    }
                    sPriceList += "</table>";
                }
        }
             
    }
}